package com.shelpe.services.lexicon.utils;

import com.shelpe.services.lexicon.entity.KeywordRecommend;
import com.shelpe.services.lexicon.properties.AutoDriveParams.Mode;

public class PriceUtils {
	
	
	public static int priceScore(Mode mode, KeywordRecommend recommend){
		int score = PriceUtils.sortScore(mode, recommend);
		if(score < mode.getSortValve()){
			score = 0;
		}else{
			score = PriceUtils.weight(recommend, mode.getPriceWeight());
		}
		return score;
	}
	
	
	public static int sortScore(Mode mode, KeywordRecommend recommend){
		return PriceUtils.weight(recommend, mode.getSortWeight());
	}
	
	/**
	 * weight 
	 * @param type
	 * @param recommend
	 * @param metric
	 * @param scope: 0 - 100
	 * @return
	 */
	public static int weight(KeywordRecommend recommend, int scope){
		float sim = ((float) recommend.getSimilarity()) / 100;
		float pqr = ((float) recommend.getPqr()) / 100;
		float s = ((float) scope) / 100;
		
		float weight = s * sim;
		weight += (1 - s) * pqr;
		return ((int) (weight * 100));
	}
}
